package com.wing.cabinet.model.entity;

import java.io.Serializable;
import java.math.BigDecimal;

import com.alibaba.cloud.commons.lang.StringUtils;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.enums.IEnum;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.wing.mybatis.common.BaseEntity;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

/**
 * 刀具编号
 *
 * @author
 */
@Data
@NoArgsConstructor
@Accessors(chain = true)
@TableName("cab_use_inventory_user_knife_inout")
public class UseInventoryUserKnifeInout extends BaseEntity<UseInventoryUserKnifeInout> implements Serializable {

    private static final long serialVersionUID = 1L;

    public enum Status implements IEnum<Integer> {



        /**
         * 在用
         */
        used(0,"在用"),
        /**
         * 在存刀柜
         */
        inTempCab(1,"在存刀柜"),
        /**
         * 在售刀柜
         */
        inCellCab(2,"在售刀柜"),

        outChecked(3,"盘验取出"),

        outCheckedLose(4,"盘验缺失"),

        returned(5,"归还"),

        loss(6,"报失");

        private int code;
        private String desc;

        Status(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }
    }

    /**
     * 创建者
     */
    private Long creator;

    /**
     * 修改者
     */
    private Long modifier;

    /**
     * 创建人
     */
    private String creatorName;

    /**
     * 修改人
     */
    private String modifierName;

    /**
     * 编号
     */
    private String code;

    /**
     * useInventoryUserId
     */
    private Long useInventoryUserId;

    /**
     * 领新id
     */
    private Long cellInventoryInoutId;

    /**
     * 状态
     */
    private Status status;

    /**
    * 状态描述
    */
    @TableField(exist = false)
    private String statusDesc;

    public String getStatusDesc() {
        return status == null ? null : status.getDesc();
    }

    /**
     * SKU编号
     */
    private String skuCode;

    /**
     * useInventoryInoutId
     */
    private Long useInventoryInoutId;

    /**
     * deviceCode
     */
    private String deviceCode;

    /**
     * 暂存id
     */
    private Long storageInventoryUserId;

    /**
     * storageInventoryInoutId
     */
    private Long storageInventoryInoutId;


    private Long checkInventoryInoutId;

    private Long checkResultId;


    public enum BusinessType implements IEnum<Integer> {

        /**
         * 业务类型:cellCabReceive(1,售刀柜领取);repairOrderSign(2,维修订单签收)
         */
        cellCabOut(1,"售刀柜领新"),

        tempIn(2,"存入暂存柜"),
        /**
         * 领取
         */
        repairOrderSign(3,"维修订单签收"),

        tempOut(4,"暂存柜取出"),

        outByReturned(5,"归还仓库管理员"),

        cellCabOutByOldNew(6,"售刀柜领新(以旧换新)"),

        /**
         * 维修
         */
        repairIn(7,"维修存入"),
        /**
         * 回收
         */
        recycleIn(8,"报废存入"),


        repairOutByCheck(9,"盘验维修取出"),

        recycleOutByCheck(10,"盘验报废取出"),

        recycleInByOldNew(11,"以旧换新存入报废"),

        tempInByCheck(12,"盘验暂存存入"),

        tempOutByCheck(13,"盘验暂存取出"),

        tempOutByCheckLose(14,"盘验暂存缺失"),

        repairOutByCheckLose(15,"盘验维修缺失"),

        recycleOutByCheckLose(16,"盘验报废缺失"),

        tempInByOldNew(17,"以旧换新存入暂存"),

        repairInByOldNew(18,"以旧换新存入维修"),

        tempOutByCheckSpec(19,"盘验暂存产品规格不相符"),

        repairOutByCheckSpec(20,"盘验维修产品规格不相符"),

        recycleOutByCheckSpec(21,"盘验报废产品规格不相符"),

        importUseByExcel(22,"导入在用"),


        newOut(24,"存刀柜新刀取出"),

        loss(31,"报失"),

        exhibit(32,"格子柜上货"),

        unload(33,"格子柜下货");


        private int code;
        private String desc;

        BusinessType(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }

        @JsonCreator
        public static BusinessType jsonCreator(String name) {
            if (StringUtils.isNotBlank(name)) {
                for (BusinessType item : values()) {
                    if (item.name().equals(name.trim())) {
                        return item;
                    }
                }
            }
            return null;
        }
    }

    private BusinessType businessType;

    private Long storageInventoryCheckId;

    @TableField(exist = false)
    private String businessTypeDesc;

    public String getBusinessTypeDesc() {
        return businessType == null ? null : businessType.getDesc();
    }

    private Long workOrderId;

    /**
     * 企业编码
     */
    private String enterpriseCode;


    private String cabCode;

    private String spaceCode;


    private Integer remainingTime;

    private Integer initTime;

    private Integer useTime;

    /**
     * 寿命单位  1：小时/ 2：次数
     */
    private LifeUnit lifeUnit;

    private Integer preTime;
    /**
     * 1：分钟/ 2：个数
     */
    public enum LifeUnit implements IEnum<Integer> {

        /**
         * 分钟
         */
        minute(1,"分钟"),
        /**
         * 个数
         */
        number(2,"个数");

        private int code;
        private String desc;

        LifeUnit(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }
        @JsonCreator
        public static LifeUnit jsonCreator(String name) {
            if (org.apache.commons.lang.StringUtils.isNotBlank(name)) {
                for (LifeUnit item : values()) {
                    if (item.name().equals(name.trim())) {
                        return item;
                    }
                }
            }
            return null;
        }
    }

    private Long categoryId;
    /**
     * 渠道编号
     */
    private String channelCode;

    private Long processId;

    private Long departmentId;

    private Long roleId;

    private String departmentName;

    private String roleName;

    private BigDecimal price;
}
